package com.example.aitoedu.task;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.aitoedu.entity.TeaSign;
import com.example.aitoedu.mapper.TeaSignMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

//@Component
@Slf4j
public class SetSignEnd {

    @Autowired
    private TeaSignMapper teaSignMapper;

    @Scheduled(cron = "0/5 * * * * ?")
    public void end(){
        TeaSign teaSign = new TeaSign();
        teaSign.setIsEnd(1);
        teaSignMapper.update(teaSign, new QueryWrapper<TeaSign>().lt("end_time", LocalDateTime.now())
                .eq("is_end",0));
    }
}
